#include <iostream>

class Test
{
public:
    Test()
    {
        std::cout<<"构造函数"<<std::endl;
    }
    void show()
    {
        std::cout<<"helloworld"<<std::endl;
    }
    ~Test()
    {
        std::cout<<"析构函数"<<std::endl;
    }

};

class SmartPoint
{
public:
    SmartPoint(Test *t)
    {
        this->t = t;
    }
    
    ~SmartPoint()
    {
        delete t;
    }

    Test* operator->()//不把指针取出来的情况下，调用这个函数
    {
        return t;
    }

    Test& operator*()
    {
        return *t;
    }

private:
    Test *t;
};

int main()
{
    //Test *t = new Test;
    SmartPoint p(new Test);//内存托管
    p->show();//重载箭头符号->
    Test obj = *p;//重载解引用符号*，让内存托管类能像指针一样使用
    return 0;
}